python format currency

49

format integer to be money python -

formatted_float = "${:,.2f}".format(1500.2)

python convert long floats to usd -

def as_currency(amount):
    if amount >= 0:
        return '${:,.2f}'.format(amount)
    else:
        return '-${:,.2f}'.format(-amount)

Comments

Submit
0 Comments